<script setup lang="ts">
import { ref, onMounted } from "vue";
import { invoke } from "@tauri-apps/api/core";

// 定义数据类型
interface TodoItem {
  id: number;
  title: string;
  content?: string;
  completed: boolean;
  created_at: string;
  updated_at: string;
}

interface Note {
  id: number;
  title: string;
  content: string;
  todo_id?: number;
  created_at: string;
  updated_at: string;
}

// 响应式数据
const todos = ref<TodoItem[]>([]);
const notes = ref<Note[]>([]);
const newTodoTitle = ref("");
const newTodoContent = ref("");
const newNoteTitle = ref("");
const newNoteContent = ref("");
const selectedTodoId = ref<number | null>(null);
const showNoteModal = ref(false);
const activeTab = ref<'todos' | 'notes'>('todos');

// 加载状态
const loading = ref(false);

// 初始化数据库

// 获取所有待办事项
async function fetchTodos() {
  try {
    loading.value = true;
    const result = await invoke('get_todos');
    todos.value = result as TodoItem[];
    console.log('获取待办事项:', result);
  } catch (error) {
    console.error('获取待办事项失败:', error);
  } finally {
    loading.value = false;
  }
}

// 获取所有便签
async function fetchNotes() {
  try {
    const result = await invoke('get_notes');
    notes.value = result as Note[];
    console.log('获取便签:', result);
  } catch (error) {
    console.error('获取便签失败:', error);
  }
}

// 创建新待办事项
async function createTodo() {
  if (!newTodoTitle.value.trim()) return;
  
  try {
    const result = await invoke('create_todo', {
      request: {
        title: newTodoTitle.value.trim(),
        content: newTodoContent.value.trim() || null
      }
    });
    
    console.log('创建待办事项成功:', result);
    todos.value.unshift(result as TodoItem);
    newTodoTitle.value = '';
    newTodoContent.value = '';
  } catch (error) {
    console.error('创建待办事项失败:', error);
  }
}

// 更新待办事项
async function updateTodo(todo: TodoItem, updates: Partial<TodoItem>) {
  try {
    const result = await invoke('update_todo', {
      request: {
        id: todo.id,
        ...updates
      }
    });
    
    console.log('更新待办事项成功:', result);
    const index = todos.value.findIndex(t => t.id === todo.id);
    if (index !== -1) {
      todos.value[index] = result as TodoItem;
    }
  } catch (error) {
    console.error('更新待办事项失败:', error);
  }
}

// 删除待办事项
async function deleteTodo(id: number) {
  try {
    await invoke('delete_todo', { id });
    console.log('删除待办事项成功:', id);
    todos.value = todos.value.filter(t => t.id !== id);
  } catch (error) {
    console.error('删除待办事项失败:', error);
  }
}

// 切换待办事项状态
function toggleTodoComplete(todo: TodoItem) {
  updateTodo(todo, { completed: !todo.completed });
}

// 创建新便签
async function createNote() {
  if (!newNoteTitle.value.trim() || !newNoteContent.value.trim()) return;
  
  try {
    const result = await invoke('create_note', {
      request: {
        title: newNoteTitle.value.trim(),
        content: newNoteContent.value.trim(),
        todo_id: selectedTodoId.value
      }
    });
    
    console.log('创建便签成功:', result);
    notes.value.unshift(result as Note);
    newNoteTitle.value = '';
    newNoteContent.value = '';
    selectedTodoId.value = null;
    showNoteModal.value = false;
  } catch (error) {
    console.error('创建便签失败:', error);
  }
}

// 删除便签
async function deleteNote(id: number) {
  try {
    await invoke('delete_note', { id });
    console.log('删除便签成功:', id);
    notes.value = notes.value.filter(n => n.id !== id);
  } catch (error) {
    console.error('删除便签失败:', error);
  }
}

// 组件挂载时初始化
onMounted(async () => {
  try {
    // 初始化数据库
    await invoke('init_database');
    console.log('数据库初始化成功');
    
    // 加载现有数据
    await Promise.all([fetchTodos(), fetchNotes()]);
    console.log('数据加载完成');
  } catch (error) {
    console.error('初始化失败:', error);
  }
});

// 格式化日期
function formatDate(dateString: string) {
  const date = new Date(dateString);
  return date.toLocaleString('zh-CN', {
    year: 'numeric',
    month: 'short',
    day: 'numeric',
    hour: '2-digit',
    minute: '2-digit'
  });
}

// 获取关联的待办事项
function getRelatedTodo(todoId?: number) {
  if (!todoId) return null;
  return todos.value.find(t => t.id === todoId);
}

// 简单的 Markdown 格式化
function formatMarkdown(text: string) {
  return text
    .replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>') // 粗体
    .replace(/\*(.*?)\*/g, '<em>$1</em>') // 斜体
    .replace(/`(.*?)`/g, '<code>$1</code>') // 行内代码
    .replace(/\n/g, '<br>'); // 换行
}
</script>


<template>
  <div class="app-container">
    <!-- 背景装饰 -->
    <div class="background-decoration">
      <div class="floating-heart heart-1">💕</div>
      <div class="floating-heart heart-2">💖</div>
      <div class="floating-heart heart-3">💝</div>
      <div class="floating-heart heart-4">💗</div>
    </div>

    <!-- 主内容区域 -->
    <main class="main-content">
      <!-- 标题 -->
      <header class="app-header">
        <h1 class="app-title">开始你的待办事项</h1>
        <p class="app-subtitle">用心记录，用爱生活 🌸</p>
      </header>

      <!-- 标签页切换 -->
      <div class="tab-container">
        <button 
          :class="['tab-button', { active: activeTab === 'todos' }]"
          @click="activeTab = 'todos'"
        >
          📝 待办事项
        </button>
        <button 
          :class="['tab-button', { active: activeTab === 'notes' }]"
          @click="activeTab = 'notes'"
        >
          📜 便签笔记
        </button>
      </div>

      <!-- 待办事项面板 -->
      <div v-if="activeTab === 'todos'" class="todo-panel">
        <!-- 新增待办事项表单 -->
        <div class="input-section">
          <div class="input-group">
            <input
              v-model="newTodoTitle"
              type="text"
              placeholder="输入你的待办事项..."
              class="todo-input title-input"
              @keypress.enter="createTodo"
            />
            <textarea
              v-model="newTodoContent"
              placeholder="添加详细描述（可选）"
              class="todo-input content-input"
              rows="2"
            ></textarea>
            <button 
              @click="createTodo"
              class="add-button"
              :disabled="!newTodoTitle.trim()"
            >
              <span>添加</span>
              <div class="button-decoration">
                <span class="heart">💖</span>
              </div>
            </button>
          </div>
        </div>

        <!-- 待办事项列表 -->
        <div class="todos-container">
          <div v-if="loading" class="loading">
            <div class="loading-spinner"></div>
            <p>正在加载...</p>
          </div>
          
          <div v-else-if="todos.length === 0" class="empty-state">
            <div class="empty-illustration">🌱</div>
            <p>还没有待办事项，赶快添加一个吧！</p>
          </div>
          
          <div v-else class="todos-list">
            <div 
              v-for="todo in todos" 
              :key="todo.id"
              :class="['todo-item', { completed: todo.completed }]"
            >
              <div class="todo-content">
                <button 
                  @click="toggleTodoComplete(todo)"
                  :class="['checkbox', { checked: todo.completed }]"
                >
                  <span v-if="todo.completed" class="checkmark">✓</span>
                </button>
                
                <div class="todo-text">
                  <h3 class="todo-title">{{ todo.title }}</h3>
                  <p v-if="todo.content" class="todo-description">{{ todo.content }}</p>
                  <span class="todo-date">{{ formatDate(todo.created_at) }}</span>
                </div>
              </div>
              
              <div class="todo-actions">
                <button 
                  @click="deleteTodo(todo.id)"
                  class="delete-button"
                  title="删除"
                >
                  🗑️
                </button>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 便签面板 -->
      <div v-if="activeTab === 'notes'" class="notes-panel">
        <!-- 新增便签按钮 -->
        <div class="notes-header">
          <button 
            @click="showNoteModal = true"
            class="add-note-button"
          >
            ➕ 新增便签
          </button>
        </div>

        <!-- 便签列表 -->
        <div class="notes-container">
          <div v-if="notes.length === 0" class="empty-state">
            <div class="empty-illustration">📝</div>
            <p>还没有便签，创建一个快速笔记吧！</p>
          </div>
          
          <div v-else class="notes-grid">
            <div 
              v-for="note in notes" 
              :key="note.id"
              class="note-card"
            >
              <div class="note-header">
                <h3 class="note-title">{{ note.title }}</h3>
                <button 
                  @click="deleteNote(note.id)"
                  class="note-delete"
                  title="删除便签"
                >
                  ×
                </button>
              </div>
              
              <div class="note-content" v-html="formatMarkdown(note.content)"></div>
              
              <div class="note-footer">
                <span v-if="getRelatedTodo(note.todo_id)" class="related-todo">
                  🔗 {{ getRelatedTodo(note.todo_id)?.title }}
                </span>
                <span class="note-date">{{ formatDate(note.created_at) }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </main>

    <!-- 便签创建模态框 -->
    <div v-if="showNoteModal" class="modal-overlay" @click="showNoteModal = false">
      <div class="modal-content" @click.stop>
        <div class="modal-header">
          <h2>创建新便签</h2>
          <button @click="showNoteModal = false" class="close-button">×</button>
        </div>
        
        <div class="modal-body">
          <input
            v-model="newNoteTitle"
            type="text"
            placeholder="便签标题"
            class="note-input"
          />
          
          <textarea
            v-model="newNoteContent"
            placeholder="输入便签内容（支持 Markdown 语法）"
            class="note-textarea"
            rows="6"
          ></textarea>
          
          <select v-model="selectedTodoId" class="todo-select">
            <option :value="null">不关联待办事项</option>
            <option 
              v-for="todo in todos.filter(t => !t.completed)" 
              :key="todo.id"
              :value="todo.id"
            >
              {{ todo.title }}
            </option>
          </select>
        </div>
        
        <div class="modal-footer">
          <button @click="showNoteModal = false" class="cancel-button">取消</button>
          <button 
            @click="createNote"
            class="confirm-button"
            :disabled="!newNoteTitle.trim() || !newNoteContent.trim()"
          >
            创建
          </button>
        </div>
      </div>
    </div>
  </div>
</template>


<style scoped>
/* 全局样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 应用容器 */
.app-container {
  min-height: 100vh;
  background: linear-gradient(135deg, 
    #faf9f6 0%, 
    #fff8e7 25%, 
    #ffefd5 50%, 
    #fff0f5 75%, 
    #f8f6ff 100%);
  position: relative;
  overflow-x: hidden;
  font-family: 'Comic Sans MS', 'Microsoft YaHei', sans-serif;
}

/* 背景装饰 */
.background-decoration {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.floating-heart {
  position: absolute;
  font-size: 1.5rem;
  opacity: 0.1;
  animation: float 6s ease-in-out infinite;
}

.heart-1 {
  top: 10%;
  left: 10%;
  animation-delay: 0s;
}

.heart-2 {
  top: 20%;
  right: 15%;
  animation-delay: 1.5s;
}

.heart-3 {
  bottom: 25%;
  left: 20%;
  animation-delay: 3s;
}

.heart-4 {
  bottom: 15%;
  right: 10%;
  animation-delay: 4.5s;
}

@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  25% { transform: translateY(-10px) rotate(2deg); }
  50% { transform: translateY(-5px) rotate(-1deg); }
  75% { transform: translateY(-15px) rotate(1deg); }
}

/* 主内容区域 */
.main-content {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
  min-height: 100vh;
}

/* 标题区域 */
.app-header {
  text-align: center;
  margin-bottom: 3rem;
  animation: slideInDown 0.8s ease-out;
}

.app-title {
  font-size: 2.5rem;
  color: #8b5a8c;
  margin-bottom: 0.5rem;
  text-shadow: 2px 2px 4px rgba(139, 90, 140, 0.2);
  font-weight: bold;
  background: linear-gradient(45deg, #8b5a8c, #d8a7ca);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-subtitle {
  font-size: 1.1rem;
  color: #a67c8a;
  font-style: italic;
}

/* 标签页切换 */
.tab-container {
  display: flex;
  justify-content: center;
  margin-bottom: 2rem;
  gap: 1rem;
}

.tab-button {
  padding: 0.8rem 2rem;
  border: none;
  border-radius: 25px;
  background: rgba(255, 255, 255, 0.7);
  color: #8b5a8c;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  border: 2px solid transparent;
}

.tab-button:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(139, 90, 140, 0.2);
}

.tab-button.active {
  background: linear-gradient(45deg, #d8a7ca, #f4c2c2);
  color: white;
  border-color: #8b5a8c;
  box-shadow: 0 4px 15px rgba(139, 90, 140, 0.3);
}

/* 输入区域 */
.input-section {
  margin-bottom: 2rem;
  animation: slideInUp 0.8s ease-out 0.2s both;
}

.input-group {
  background: rgba(255, 255, 255, 0.8);
  padding: 2rem;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.todo-input {
  width: 100%;
  border: 2px solid #e8d8e8;
  border-radius: 15px;
  padding: 1rem;
  font-size: 1rem;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.9);
  margin-bottom: 1rem;
  font-family: inherit;
}

.todo-input:focus {
  outline: none;
  border-color: #d8a7ca;
  box-shadow: 0 0 0 3px rgba(216, 167, 202, 0.2);
  transform: translateY(-1px);
}

.title-input {
  font-size: 1.2rem;
  font-weight: 600;
}

.content-input {
  resize: vertical;
  min-height: 60px;
}

/* 添加按钮 */
.add-button {
  position: relative;
  background: linear-gradient(45deg, #d8a7ca, #f4c2c2);
  color: white;
  border: none;
  border-radius: 25px;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(216, 167, 202, 0.4);
}

.add-button:not(:disabled):hover {
  background: linear-gradient(45deg, #c191b8, #e8a8a8);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(216, 167, 202, 0.5);
}

.add-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.button-decoration {
  position: absolute;
  top: -5px;
  right: -5px;
  opacity: 0.3;
}

.heart {
  font-size: 0.8rem;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* 待办事项容器 */
.todos-container {
  animation: slideInUp 0.8s ease-out 0.4s both;
}

.loading {
  text-align: center;
  padding: 3rem;
  color: #8b5a8c;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e8d8e8;
  border-top: 4px solid #d8a7ca;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: #a67c8a;
}

.empty-illustration {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.7;
}

/* 待办事项列表 */
.todos-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.todo-item {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 15px;
  padding: 1.5rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.todo-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.todo-item.completed {
  opacity: 0.7;
  background: rgba(232, 232, 232, 0.8);
}

.todo-item.completed .todo-title {
  text-decoration: line-through;
  color: #999;
}

.todo-content {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex: 1;
}

.checkbox {
  width: 24px;
  height: 24px;
  border: 2px solid #d8a7ca;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
  margin-top: 2px;
}

.checkbox:hover {
  background: rgba(216, 167, 202, 0.1);
}

.checkbox.checked {
  background: #d8a7ca;
  color: white;
}

.checkmark {
  font-weight: bold;
  font-size: 0.9rem;
}

.todo-text {
  flex: 1;
}

.todo-title {
  font-size: 1.2rem;
  color: #333;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.todo-description {
  color: #666;
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.todo-date {
  font-size: 0.9rem;
  color: #999;
}

.todo-actions {
  display: flex;
  gap: 0.5rem;
}

.delete-button {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: all 0.3s ease;
  opacity: 0.6;
}

.delete-button:hover {
  background: rgba(255, 107, 107, 0.1);
  opacity: 1;
  transform: scale(1.1);
}

/* 便签面板 */
.notes-panel {
  animation: slideInUp 0.8s ease-out 0.2s both;
}

.notes-header {
  display: flex;
  justify-content: center;
  margin-bottom: 2rem;
}

.add-note-button {
  background: linear-gradient(45deg, #a8e6cf, #b8e6b8);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(168, 230, 207, 0.4);
}

.add-note-button:hover {
  background: linear-gradient(45deg, #90d4a7, #a0d6a0);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(168, 230, 207, 0.5);
}

.notes-container {
  width: 100%;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.note-card {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 15px;
  padding: 1.5rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(10px);
  position: relative;
}

.note-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.note-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.note-title {
  font-size: 1.3rem;
  color: #333;
  font-weight: 600;
  flex: 1;
  margin-right: 1rem;
}

.note-delete {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #999;
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 50%;
  transition: all 0.3s ease;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.note-delete:hover {
  background: rgba(255, 107, 107, 0.1);
  color: #ff6b6b;
}

.note-content {
  color: #555;
  line-height: 1.6;
  margin-bottom: 1rem;
  white-space: pre-wrap;
}

.note-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: #999;
}

.related-todo {
  background: rgba(216, 167, 202, 0.2);
  padding: 0.3rem 0.8rem;
  border-radius: 12px;
  color: #8b5a8c;
  font-size: 0.8rem;
}

.note-date {
  font-size: 0.8rem;
}

/* 模态框 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background: white;
  border-radius: 20px;
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideInScale 0.3s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h2 {
  color: #333;
  font-size: 1.5rem;
  margin: 0;
}

.close-button {
  background: none;
  border: none;
  font-size: 1.8rem;
  color: #999;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.close-button:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #333;
}

.modal-body {
  margin-bottom: 1.5rem;
}

.note-input, .note-textarea, .todo-select {
  width: 100%;
  border: 2px solid #e8d8e8;
  border-radius: 10px;
  padding: 0.8rem;
  font-size: 1rem;
  transition: all 0.3s ease;
  margin-bottom: 1rem;
  font-family: inherit;
}

.note-input:focus, .note-textarea:focus, .todo-select:focus {
  outline: none;
  border-color: #a8e6cf;
  box-shadow: 0 0 0 3px rgba(168, 230, 207, 0.2);
}

.note-textarea {
  resize: vertical;
  min-height: 120px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.cancel-button, .confirm-button {
  padding: 0.8rem 1.5rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.cancel-button {
  background: #f5f5f5;
  color: #666;
}

.cancel-button:hover {
  background: #e8e8e8;
}

.confirm-button {
  background: linear-gradient(45deg, #a8e6cf, #b8e6b8);
  color: white;
}

.confirm-button:not(:disabled):hover {
  background: linear-gradient(45deg, #90d4a7, #a0d6a0);
  transform: translateY(-1px);
}

.confirm-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 动画 */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInScale {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .main-content {
    padding: 1rem;
  }
  
  .app-title {
    font-size: 2rem;
  }
  
  .tab-container {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .todo-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .todo-content {
    width: 100%;
  }
  
  .todo-actions {
    align-self: flex-end;
  }
  
  .notes-grid {
    grid-template-columns: 1fr;
  }
  
  .modal-content {
    margin: 1rem;
    width: calc(100% - 2rem);
  }
}
</style>